package at.fhooe.tof.common;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Common {
	
	public static float convert4BytesToFloat(byte[] bytes){
		try{
			if(bytes.length!=4){
				throw new Exception("Byte array size is greater than 4.");
			}else{
				byte[] byteArray = bytes;
				
				ByteBuffer buffer = ByteBuffer.wrap(byteArray);
				buffer.order(ByteOrder.LITTLE_ENDIAN);
				float fVal = buffer.getFloat();
				
				return fVal;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return 0;
	}

}
